//
//  InformationsOfGoodViewController.m
//  ios-test
//
//  Created by Apple -11 on 15/10/14.
//  Copyright (c) 2015年 Apple -11. All rights reserved.
//

#import "InformationsOfGoodViewController.h"
#import "Define.pch"
#import "ForivteViewController.h"
//#import "goodsViewController.h"
@interface InformationsOfGoodViewController ()

@end

@implementation InformationsOfGoodViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    //forivteController=[[ForivteViewController alloc]init];
    [self.view sizeToFit];
    
    scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 60,SCREENWIDTH, SCREENHEIGHT-120)];
    scrollView.contentSize=CGSizeMake(0, SCREENHEIGHT);
    scrollView.delegate=self;
    [scrollView setScrollEnabled:YES];
    
    [self Line];
    [self FirstView];
    [self SecondView];
    [self Others];
    
    scrollView.contentSize=CGSizeMake(0, 1000);
    [self.view addSubview:scrollView];
    
    forivte= [NSUserDefaults standardUserDefaults];
    share= [NSUserDefaults standardUserDefaults];
    self.forivteArray=[NSMutableArray array];
    self.shareArray=[NSMutableArray array];
    

    // Do any additional setup after loading the view from its nib.
}
//显示信息
-(void)viewWillAppear:(BOOL)animated{
    
    myImageView.image=[UIImage imageNamed:self.dict[@"icon"]];
    titleLabel.text=self.dict[@"title"];
    priceLabel.text=[NSString stringWithFormat:@"￥%@",self.dict[@"price"]];
    comment.text=[NSString stringWithFormat:@"%@好评",self.dict[@"comment"]];
    purchaseNum.text=[NSString stringWithFormat:@"已有%@人购买",self.dict[@"purchaseNum"]];
}
//划线
-(void)Line{
    UIView *lineView1=[[UIView alloc] initWithFrame:CGRectMake(0, 220,SCREENWIDTH,1)];
    lineView1.backgroundColor=[UIColor lightGrayColor];
    [scrollView addSubview:lineView1];
    UIView *lineView2=[[UIView alloc] initWithFrame:CGRectMake(0, 280,SCREENWIDTH,1)];
    lineView2.backgroundColor=[UIColor lightGrayColor];
    [scrollView addSubview:lineView2];
    UIView *lineView3=[[UIView alloc] initWithFrame:CGRectMake(0, 360,SCREENWIDTH,1)];
    lineView3.backgroundColor=[UIColor lightGrayColor];
    [scrollView addSubview:lineView3];
    UIView *lineView4=[[UIView alloc] initWithFrame:CGRectMake(0, 410,SCREENWIDTH,1)];
    lineView4.backgroundColor=[UIColor lightGrayColor];
    [scrollView addSubview:lineView4];
    UIView *lineView5=[[UIView alloc] initWithFrame:CGRectMake(0, 440,SCREENWIDTH,1)];
    lineView5.backgroundColor=[UIColor lightGrayColor];
    [scrollView addSubview:lineView5];
    UIView *lineView6=[[UIView alloc] initWithFrame:CGRectMake(0, 490,SCREENWIDTH,1)];
    lineView6.backgroundColor=[UIColor lightGrayColor];
    [scrollView addSubview:lineView6];
}
//FirstView
-(void)FirstView{
    UIView *firstView=[[UIView alloc]initWithFrame:CGRectMake(0, 220, SCREENWIDTH, 60)];
    titleLabel=[[UILabel alloc]initWithFrame:CGRectMake(10,0,firstView.frame.size.width-100, 60)];
    titleLabel.numberOfLines=2;
    titleLabel.font=[UIFont boldSystemFontOfSize:15.0];
    [firstView addSubview:titleLabel];
    
    UIView *lineView=[[UIView alloc] initWithFrame:CGRectMake(firstView.frame.size.width-79, 5, 1,50 )];
    lineView.backgroundColor=[UIColor lightGrayColor];
    [firstView addSubview:lineView];
    
    UIButton *button =[[UIButton alloc]initWithFrame:CGRectMake(firstView.frame.size.width-65, 10, 40, 40)];
    [button setBackgroundImage:[UIImage imageNamed:@"lianjie.png"] forState:UIControlStateNormal];
    [firstView addSubview:button];
    [button addTarget:self action:@selector(share) forControlEvents:UIControlEventTouchUpInside];
     
    [scrollView addSubview:firstView];

}
//SecondView
-(void)SecondView{
    UIView *secondView=[[UIView alloc]initWithFrame:CGRectMake(0, 280, SCREENWIDTH, 80)];
    priceLabel=[[UILabel alloc]initWithFrame:CGRectMake(10,10,150, 40)];
    priceLabel.font=[UIFont boldSystemFontOfSize:25.0];
    //priceLabel.backgroundColor=[UIColor orangeColor];
    priceLabel.textColor=[UIColor redColor];
    [secondView addSubview:priceLabel];
    
    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(14,50,100, 30)];
    label.font=[UIFont boldSystemFontOfSize:13.0];
    label.text=@"免运费";
    //label.backgroundColor=[UIColor orangeColor];
    
    label.textColor=[UIColor lightGrayColor];
    [secondView addSubview:label];
    
    comment=[[UILabel alloc]initWithFrame:CGRectMake(SCREENWIDTH-110,20,70,20)];
    comment.backgroundColor=[UIColor redColor];
    comment.font=[UIFont boldSystemFontOfSize:13.0];
    comment.textColor=[UIColor whiteColor];
    //comment.backgroundColor=[UIColor orangeColor];
    
    [secondView addSubview:comment];
    
    
    purchaseNum=[[UILabel alloc]initWithFrame:CGRectMake(SCREENWIDTH-120,45,100,40)];
    purchaseNum.textColor=[UIColor lightGrayColor];
    purchaseNum.font=[UIFont boldSystemFontOfSize:13.0];
    //purchaseNum.backgroundColor=[UIColor orangeColor];
    
    
    [secondView addSubview:purchaseNum];
    [scrollView addSubview:secondView];
}
//Other
-(void)Others{
    myImageView=[[UIImageView alloc] initWithFrame:CGRectMake(2, 2, SCREENWIDTH-4, 200)];
    myImageView.contentMode=UIViewContentModeScaleAspectFit;
    [scrollView addSubview:myImageView];
    
    UIButton *sizeButton=[[UIButton  alloc]initWithFrame:CGRectMake(10, 361, SCREENWIDTH, 50)];
    [sizeButton setTitle:@"选择 尺寸,颜色分类" forState:UIControlStateNormal];
    [sizeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    sizeButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    UILabel *label=[[UILabel  alloc]initWithFrame:CGRectMake(SCREENWIDTH-100, 5, 100, 40)];
    label.text=@"尺码:M 蓝色";
    label.font=[UIFont boldSystemFontOfSize:13.0];
    label.textColor=[UIColor lightGrayColor];
    [sizeButton addSubview:label];
    [scrollView addSubview:sizeButton];
    
    UILabel *newslabel=[[UILabel  alloc]initWithFrame:CGRectMake(10, 441, SCREENWIDTH, 50)];
    newslabel.text=@"商品评价";
    newslabel.font=[UIFont boldSystemFontOfSize:18.0];
    newslabel.textColor=[UIColor blackColor];
    [scrollView addSubview:newslabel];

}
-(void)share{
    if ([share objectForKey:@"share"]) {
        self.shareArray=[share objectForKey:@"share"];
    }
    //self.shareArray=[share objectForKey:@"share"];
    [self.shareArray addObject:self.dict];
    
    [share setObject:self.shareArray forKey:@"share"];
    UIAlertView *alter=nil;
    alter=[[UIAlertView alloc]initWithTitle:@"警告！！！！" message:@"成功分享" delegate:nil cancelButtonTitle:@"close" otherButtonTitles:nil, nil];
    [alter show];

}

-(IBAction)forivteGood:(id)sender{

    if ([forivte objectForKey:@"forivate"]!=NULL) {
        self.forivteArray=[forivte objectForKey:@"forivate"];
    }
    
    
    [self.forivteArray addObject:self.dict];
    [forivte setObject:self.forivteArray forKey:@"forivate"];
    UIAlertView *alter=nil;
    alter=[[UIAlertView alloc]initWithTitle:@"警告！！！！" message:@"收藏成功" delegate:nil cancelButtonTitle:@"close" otherButtonTitles:nil, nil];
    [alter show];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(IBAction)exitTo:(id)sender{
//    goodsViewController *goods=[[goodsViewController alloc]init];
//    goods.modalTransitionStyle=UIModalTransitionStyleCrossDissolve;
//    [self presentViewController:goods animated:YES completion:nil];
    [self dismissViewControllerAnimated:YES completion:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
